﻿using Microsoft.AspNetCore.Cryptography.KeyDerivation;
using System;
using System.Text;

namespace Basefr.Runtime.Helpers
{
    public static class HashHelper
    {
        public static string Hash(string value, string salt)
        {
            var bytes = KeyDerivation.Pbkdf2(value, Encoding.UTF8.GetBytes(salt), KeyDerivationPrf.HMACSHA512, 10000, 256 / 8);

            return Convert.ToBase64String(bytes);
        }

        public static bool Validate(string value, string salt, string hash) => Hash(value, salt) == hash;
    }
}
